package com.jinmdz.fmis.api.admin.controller;

import com.jinmdz.fmis.api.admin.model.hall.HallIdData;
import com.jinmdz.fmis.api.admin.model.hall.HallListData;
import com.jinmdz.fmis.api.admin.model.hall.HallLoadData;
import com.jinmdz.fmis.api.admin.model.hall.HallSaveData;
import com.jinmdz.fmis.api.admin.service.HallService;
import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * 礼厅维护信息相关接口
 *
 * @author LiCongLu
 * @date 2020-03-11 20:59
 */
@Api(description = "礼厅维护信息相关接口")
@RestController()
@RequestMapping("/admin/hall")
public class HallController extends BaseController {

    @Resource
    private HallService hallService;

    /**
     * 加载礼厅信息
     *
     * @param
     * @return
     * @author LiCongLu
     * @date 2020-03-11 20:59
     */
    @ApiOperation(value = "加载礼厅信息", notes = "加载礼厅分类【mourn_ceremony_hall】表中所有有效礼厅信息")
    @PostMapping("/load-hall-list")
    public BaseResult<ArrayList<HallListData>> loadHallList() {
        return resultHandler(userItem -> hallService.loadHallList());
    }

    /**
     * 加载礼厅信息
     *
     * @param data 主键
     * @return
     * @author LiCongLu
     * @date 2020-03-11 20:59
     */
    @ApiOperation(value = "根据【mourn_ceremony_hall】表中id加载礼厅信息", notes = "根据ID加载礼厅信息")
    @PostMapping("/load-hall-with-id")
    public BaseResult<HallLoadData> loadHallWithId(@RequestBody HallIdData data) {
        return resultHandler(data, userItem -> hallService.loadHallWithId(data));
    }

    /**
     * 保存礼厅信息到mourn_ceremony_hall表中
     *
     * @param data 礼厅请求数据
     * @return
     * @author LiCongLu
     * @date 2020-03-11 20:59
     */
    @ApiOperation(value = "保存礼厅信息到【mourn_ceremony_hall】表中", notes = "保存礼厅信息到【mourn_ceremony_hall】表中")
    @PostMapping("/save-hall")
    public BaseResult saveHall(@RequestBody HallSaveData data) {
        return resultHandler(data, userItem -> hallService.saveHall(userItem, data));
    }

    /**
     * 从mourn_ceremony_hall表中删除指定id的礼厅信息记录
     *
     * @param data 主键和版本号
     * @return
     * @author LiCongLu
     * @date 2020-03-11 21:00
     */
    @ApiOperation(value = "从mourn_ceremony_hall表中删除指定id的礼厅信息记录", notes = "从mourn_ceremony_hall表中删除指定id的礼厅信息")
    @PostMapping("/delete-hall-with-id")
    public BaseResult deleteHallWithId(@RequestBody ArrayList<IdVersionData> data) {
        return resultHandler(data, userItem -> hallService.deleteHallWithId(userItem, data));
    }
}
